@extends('system.frame_layout')
<?php $parent_menu = "财务中心"; $menu_selected = "打款申请";?>

@section('content')
    <div id="content-panel">
        <div class="row">
            <div class="col-xs-12">
                <div class="portlet light bordered">
                    <div class="portlet-title">
                        <div class="caption">
                            <i class="icon-social-dribbble font-dark hide"></i>
                            <span class="caption-subject font-dark bold">打款申请单 Remit Apply</span>
                        </div>
                    </div>
                    <div class="portlet-body">
                        <div class="form-group">
                            <form id="remit" action="{{route('sys.remit.save')}}" method="post"
                                  enctype="multipart/form-data">
                                {{csrf_field()}}

                                <div class="form-body">
                                    <div class="alert alert-danger">
                                        <strong>警告：</strong> 请认真核对帐号，并确保无误后进行打款，请谨慎操作！
                                    </div>
                                    <div class="row input-row" style="position: relative;">

                                        <label class="col-xs-12 title" for="exampleInputPassword1">
                                            用户名 - User Name
                                        </label>
                                        <div class="col-md-4 col-xs-12">
                                            <div class="input-group">
                                                    <span class="input-group-addon">
                                                        <i class="iconfont icon-bixuan-copy font-red"></i>
                                                    </span>
                                                <input style="border: 1px solid #e1e1e1;" type="text"
                                                       class="form-control"
                                                       id="uname" name="uname" value="{{$user->username or ''}}"
                                                       readonly>
                                            </div>
                                        </div>
                                        <div class="col-xs-12 col-md-3">
                                            <label class="label-intro"></label>
                                        </div>

                                        <div class="col-md-4 col-xs-12"
                                             style="border: 2px dotted #F2DEDE;position: absolute;top: 0;right: 150px;width:500px;">
                                            <h4 style="padding-left: 50px;box-sizing: border-box"><b>对公账户信息核对</b></h4>
                                            <div class="alert alert-success">
                                                <div style="padding-left: 30px;box-sizing: border-box">
                                                    <strong>银行卡号：</strong> {{cache('kv_card_no')}}</div>
                                                <br>
                                                <div style="padding-left: 30px;box-sizing: border-box">
                                                    <strong>银行卡开户姓名：</strong> {{cache('kv_card_name')}}</div>
                                            </div>
                                            <div class="alert alert-success">
                                                <div style="padding-left: 30px;box-sizing: border-box">
                                                    <strong>支付宝帐号：</strong> {{cache('kv_alipay_no')}}</div>
                                                <br>
                                                <div style="padding-left: 30px;box-sizing: border-box">
                                                    <strong>支付宝开户姓名：</strong> {{cache('kv_alipay_name')}}</div>
                                            </div>
                                            <div class="alert alert-danger">
                                                <div style="padding-left: 30px;box-sizing: border-box">
                                                    <strong>备注信息：</strong> 对公账户购买购物币时，打款账户姓名请与会员帐户姓名保持一致，否则不予充值！</div>

                                            </div>
                                        </div>

                                    </div>

                                    <div class="row input-row">
                                        <label class="col-xs-12 title" for="exampleInputPassword1">
                                            真实姓名 - Real Name
                                        </label>
                                        <div class="col-md-4 col-xs-12">
                                            <div class="input-group">
                                                    <span class="input-group-addon">
                                                        <i class="iconfont icon-bixuan-copy font-red"></i>
                                                    </span>
                                                <input style="border: 1px solid #e1e1e1;"
                                                       id="name" name="name" type="text" class="form-control"
                                                       placeholder="请输入您的真实姓名" value="{{$user->realname or ''}}">
                                            </div>
                                        </div>
                                        <div class="col-xs-12 col-md-6">
                                            <label class="label-intro"></label>
                                        </div>
                                    </div>

                                    <div class="row input-row">
                                        <label class="col-xs-12 title" for="exampleInputPassword1">
                                            联系方式 - Contact information
                                        </label>
                                        <div class="col-md-4 col-xs-12">
                                            <div class="input-group">
                                                    <span class="input-group-addon">
                                                        <i class="iconfont icon-bixuan-copy font-red"></i>
                                                    </span>
                                                <input style="border: 1px solid #e1e1e1;"
                                                       id="phone" name="phone" type="text" class="form-control"
                                                       placeholder="请输入您的联系方式，如手机、电话等" value="{{$user->mobile or ''}}">
                                            </div>
                                        </div>
                                        <div class="col-xs-12 col-md-6">
                                            <label class="label-intro"></label>
                                        </div>
                                    </div>

                                    <div class="row input-row">
                                        <label class="col-xs-12 title" for="exampleInputPassword1">
                                            打款金额 - Remit Money
                                        </label>
                                        <div class="col-md-4 col-xs-12">
                                            <div class="input-group">
                                                    <span class="input-group-addon">
                                                        <i class="iconfont icon-bixuan-copy font-red"></i>
                                                    </span>
                                                <input style="border: 1px solid #e1e1e1;"
                                                       id="money" name="money" type="text" class="form-control"
                                                       placeholder="请输入打款金额">
                                            </div>
                                        </div>
                                        <div class="col-xs-12 col-md-6">
                                            <label class="label-intro"></label>
                                        </div>
                                    </div>

                                    <div class="row input-row">
                                        <label class="col-xs-12 title" for="exampleInputPassword1">
                                            打款时间 - Remit Time
                                        </label>
                                        <div class="col-md-4 col-xs-12">
                                            <div class="input-group">
                                                    <span class="input-group-addon">
                                                        <i class="iconfont icon-bixuan-copy font-red"></i>
                                                    </span>
                                                <input style="border: 1px solid #e1e1e1;"
                                                       onClick="laydate({istime: true,format: 'YYYY-MM-DD hh:mm:ss'})"
                                                       id="time" name="time" type="text" class="form-control"
                                                       placeholder="请点击选择打款时间">
                                            </div>
                                        </div>
                                        <div class="col-xs-12 col-md-6">
                                            <label class="label-intro"></label>
                                        </div>
                                    </div>

                                    <div class="row input-row">
                                        <label class="col-xs-12 title" for="exampleInputPassword1">
                                            打款方式 - Remit Way
                                        </label>
                                        <div class="col-md-4 col-xs-12">
                                            <div class="mt-radio-inline">
                                                <label class="mt-radio">
                                                    <input type="radio" name="remit_type"
                                                           value="{{\App\Models\MWithdrawLog::$PAY_TYPE_YHK}}" checked>
                                                    银行卡
                                                    <span></span>
                                                </label>
                                                <label class="mt-radio">
                                                    <input type="radio" name="remit_type"
                                                           value="{{\App\Models\MWithdrawLog::$PAY_TYPE_ZFB}}"> 支付宝
                                                    <span></span>
                                                </label>
                                                <label class="mt-radio">
                                                    <input type="radio" name="remit_type"
                                                           value="{{\App\Models\MWithdrawLog::$PAY_TYPE_WX}}"> 微信
                                                    <span></span>
                                                </label>
                                            </div>
                                        </div>
                                        <div class="col-xs-12 col-md-6">
                                            <label class="label-intro"></label>
                                        </div>
                                    </div>

                                    <div id="yhk">
                                        <div class="row input-row">
                                            <label class="col-xs-12 title" for="exampleInputPassword1">
                                                银行卡号 - Account Number
                                            </label>
                                            <div class="col-md-4 col-xs-12">
                                                <div class="input-group">
                                                    <span class="input-group-addon">
                                                        <i class="iconfont icon-bixuan-copy font-red"></i>
                                                    </span>
                                                    <input style="border: 1px solid #e1e1e1;"
                                                           id="card_no" name="card_no" type="text" class="form-control"
                                                           placeholder="请输入银行卡号">
                                                </div>
                                            </div>
                                            <div class="col-xs-12 col-md-6">
                                                <label class="label-intro"></label>
                                            </div>
                                        </div>
                                        <div class="row input-row">
                                            <label class="col-xs-12 title" for="exampleInputPassword1">
                                                开户行地址 - Bank Address
                                            </label>
                                            <div class="col-md-4 col-xs-12">
                                                <div class="input-group">
                                                    <span class="input-group-addon">
                                                        <i class="iconfont icon-bixuan-copy font-red"></i>
                                                    </span>
                                                    <input style="border: 1px solid #e1e1e1;"
                                                           id="card_addr" name="card_addr" type="text"
                                                           class="form-control"
                                                           placeholder="请输入开户行地址">
                                                </div>
                                            </div>
                                            <div class="col-xs-12 col-md-6">
                                                <label class="label-intro"></label>
                                            </div>
                                        </div>
                                        <div class="row input-row">
                                            <label class="col-xs-12 title" for="exampleInputPassword1">
                                                开户人姓名 - Account Name
                                            </label>
                                            <div class="col-md-4 col-xs-12">
                                                <div class="input-group">
                                                    <span class="input-group-addon">
                                                        <i class="iconfont icon-bixuan-copy font-red"></i>
                                                    </span>
                                                    <input style="border: 1px solid #e1e1e1;"
                                                           id="card_name" name="card_name" type="text"
                                                           class="form-control"
                                                           placeholder="请输入开户人姓名">
                                                </div>
                                            </div>
                                            <div class="col-xs-12 col-md-6">
                                                <label class="label-intro"></label>
                                            </div>
                                        </div>
                                    </div>

                                    <div id="zfb" style="display: none">
                                        <div class="row input-row">
                                            <label class="col-xs-12 title" for="exampleInputPassword1">
                                                支付宝帐号 - Alipay Number
                                            </label>
                                            <div class="col-md-4 col-xs-12">
                                                <div class="input-group">
                                                    <span class="input-group-addon">
                                                        <i class="iconfont icon-bixuan-copy font-red"></i>
                                                    </span>
                                                    <input style="border: 1px solid #e1e1e1;"
                                                           id="alipay_no" name="alipay_no" type="text"
                                                           class="form-control"
                                                           placeholder="请输入支付宝帐号">
                                                </div>
                                            </div>
                                            <div class="col-xs-12 col-md-6">
                                                <label class="label-intro"></label>
                                            </div>
                                        </div>
                                        <div class="row input-row">
                                            <label class="col-xs-12 title" for="exampleInputPassword1">
                                                支付宝开户人 - Alipay Name
                                            </label>
                                            <div class="col-md-4 col-xs-12">
                                                <div class="input-group">
                                                    <span class="input-group-addon">
                                                        <i class="iconfont icon-bixuan-copy font-red"></i>
                                                    </span>
                                                    <input style="border: 1px solid #e1e1e1;"
                                                           id="alipay_name" name="alipay_name" type="text"
                                                           class="form-control"
                                                           placeholder="请输入支付宝开户人姓名">
                                                </div>
                                            </div>
                                            <div class="col-xs-12 col-md-6">
                                                <label class="label-intro"></label>
                                            </div>
                                        </div>
                                    </div>

                                    <div id="wx" style="display: none">
                                        <div class="row input-row">
                                            <label class="col-xs-12 title" for="exampleInputPassword1">
                                                微信帐号 - WeChat Number
                                            </label>
                                            <div class="col-md-4 col-xs-12">
                                                <div class="input-group">
                                                    <span class="input-group-addon">
                                                        <i class="iconfont icon-bixuan-copy font-red"></i>
                                                    </span>
                                                    <input style="border: 1px solid #e1e1e1;"
                                                           id="wechat_no" name="wechat_no" type="text"
                                                           class="form-control"
                                                           placeholder="请输入微信帐号">
                                                </div>
                                            </div>
                                            <div class="col-xs-12 col-md-6">
                                                <label class="label-intro"></label>
                                            </div>
                                        </div>
                                        <div class="row input-row">
                                            <label class="col-xs-12 title" for="exampleInputPassword1">
                                                微信开户人 - WeChat Name
                                            </label>
                                            <div class="col-md-4 col-xs-12">
                                                <div class="input-group">
                                                    <span class="input-group-addon">
                                                        <i class="iconfont icon-bixuan-copy font-red"></i>
                                                    </span>
                                                    <input style="border: 1px solid #e1e1e1;"
                                                           id="wechat_name" name="wechat_name" type="text"
                                                           class="form-control"
                                                           placeholder="请输入微信开户人姓名">
                                                </div>
                                            </div>
                                            <div class="col-xs-12 col-md-6">
                                                <label class="label-intro"></label>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="row input-row">
                                        <label class="col-xs-12 title" for="exampleInputPassword1">
                                            备注信息 - Remarks Information
                                        </label>
                                        <div class="col-md-4 col-xs-12">
                                            <div class="input-group">
                                                    <span class="input-group-addon">
                                                        <i class="">&nbsp;&nbsp;&nbsp;&nbsp;</i>
                                                    </span>
                                                <textarea style="border: 1px solid #e1e1e1;"
                                                          id="remark" name="remark" type="text" class="form-control"
                                                          placeholder="请填写打款备注信息"></textarea>
                                            </div>
                                        </div>
                                        <div class="col-xs-12 col-md-6">
                                            <label class="label-intro"></label>
                                        </div>
                                    </div>

                                    <div class="row input-row">
                                        <label class="col-xs-12 title" for="exampleInputPassword1">
                                            打款凭证 - Remit Image
                                        </label>
                                        <div class="col-md-4 col-xs-12">
                                            <div class="input-group">
                                                    <span class="input-group-addon">
                                                        <i class="iconfont icon-bixuan-copy font-red"></i>
                                                    </span>
                                                <input style="border: 1px solid #e1e1e1;"
                                                       id="img" name="img" type="file" class="form-control">
                                            </div>
                                        </div>
                                        <div class="col-xs-12 col-md-6">
                                            <label class="label-intro"></label>
                                        </div>
                                    </div>

                                    <div class="row input-row">
                                        <div class="col-xs-12">
                                            <button type="submit" class="btn blue-madison">
                                                <i class="iconfont icon-duihao"></i>&nbsp;确认提交
                                            </button>
                                        </div>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection

@section('footer')
    <script src="{{asset('system/js/laydate/laydate.js')}}"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            laydate.skin("molv"); //大红色日期选择皮肤
            //初始化表格操作菜单
            $('.tablelist tbody tr:odd').addClass('odd');
            $(".tablelist .act").hover(function () {
                $($(this).attr("bind")).show();
            }, function () {
                $($(this).attr("bind")).hide();
            });
        });

        $(function () {
            $("input:radio[name=remit_type]").change(function () {
                var v = $(this).val();
                if (v == '{{\App\Models\MWithdrawLog::$PAY_TYPE_YHK}}') {
                    $("#yhk").show();
                    $("#zfb").hide();
                    $("#wx").hide();
                }
                if (v == '{{\App\Models\MWithdrawLog::$PAY_TYPE_ZFB}}') {
                    $("#yhk").hide();
                    $("#zfb").show();
                    $("#wx").hide();
                }
                if (v == '{{\App\Models\MWithdrawLog::$PAY_TYPE_WX}}') {
                    $("#yhk").hide();
                    $("#zfb").hide();
                    $("#wx").show();
                }
            });
        });
    </script>
    <script type="text/javascript">
        $("#remit").validate({
            rules: {
                name: {
                    required: true,
                    minlength: 2,
                    maxlength: 10
                },
                phone: {
                    required: true
                },
                money: {
                    required: true
                },
                time: {
                    required: true
                },
                img: {
                    required: true
                }
            }, errorPlacement: function (error, element) {
                $(element).closest(".input-row").find(".label-intro").html(error);
            },
            submitHandler: function (form) {
                $(form).ajaxSubmit({
                    dataType: "json",
                    type: "post",
                    beforeSubmit: function () {
                        $(form).find("button").each(function (index, elem) {
                            $(elem).attr("disabled", "disabled");
                        });
                    },
                    success: function (data) {
                        $(form).find("button").each(function (index, elem) {
                            $(elem).removeAttr("disabled");
                        });

                        if (data.code == 0) {
                            toastr["success"](data.msg);
                            setInterval(function () {
                                window.location.reload();
                            }, 2000);
                        } else {
                            toastr["error"](data.msg);
                        }
                    },
                    error: function () {
                        $(form).find("button").each(function (index, elem) {
                            $(elem).removeAttr("disabled");
                        });
                    }
                });
            }
        });
    </script>
@endsection